﻿using Common.Tool.ControlTools;
using Common.Tool.FileTools;
using Serilog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Media;

namespace Common.Tool
{
    public class LogBase
    {
        protected RichTextBox richTextBox { get; set; }
        protected ILogger log { get; set; }
        /// <summary>
        /// 插入一级标题
        /// </summary>
        protected void AppendTile1(string temp, string msg, DateTime? time = null)
        {
            time = time ?? DateTime.Now;
            RichTextBoxHelper.AppendTile1(richTextBox, temp, msg, time);
            LogHelper.Info(log, temp, msg, time);
        }
        /// <summary>
        /// 插入二级标题
        /// </summary>
        protected void AppendTile2(string temp, string msg, DateTime? time = null)
        {
            time = time ?? DateTime.Now;
            RichTextBoxHelper.AppendTile2(richTextBox, temp, msg, time);
            LogHelper.Info(log, temp, msg, time);
        }
        /// <summary>
        /// 插入信息
        /// </summary>
        protected void AppendInfo(string temp, string msg, DateTime? time = null)
        {
            time = time ?? DateTime.Now;
            RichTextBoxHelper.AppendInfo(richTextBox, temp, msg, time);
            LogHelper.Info(log, temp, msg, time);
        }
        /// <summary>
        /// 插入通信
        /// </summary>
        protected void AppendCommunication(string temp, string msg, DateTime? time = null)
        {
            time = time ?? DateTime.Now;
            RichTextBoxHelper.AppendCommunication(richTextBox, temp, msg, time);
            LogHelper.Info(log, temp, msg, time);
        }
        /// <summary>
        /// 插入提示
        /// </summary>
        protected void AppendTip( string temp, string msg, DateTime? time = null)
        {
            time = time ?? DateTime.Now;
            RichTextBoxHelper.AppendTip(richTextBox, temp, msg, time);
            LogHelper.Info(log, temp, msg, time);
        }
        /// <summary>
        /// 插入结果
        /// </summary>
        protected void AppendResult(string temp, string msg, DateTime? time = null)
        {
            time = time ?? DateTime.Now;
            RichTextBoxHelper.AppendResult(richTextBox, temp, msg, time);
            LogHelper.Info(log, temp, msg, time);
        }
        /// <summary>
        /// 插入错误
        /// </summary>
        protected void AppendErr(string temp, string msg, Exception ex = null, DateTime? time = null)
        {
            time = time ?? DateTime.Now;
            RichTextBoxHelper.AppendErr(richTextBox, temp, msg, time);
            LogHelper.Error(log, temp, msg, ex, time);
        }
    }
}
